/// 应用状态枚举
enum AppStatus {
  /// 初始状态
  initial,
  
  /// 初始化中
  initializing,
  
  /// 加载中
  loading,
  
  /// 已加载
  loaded,
  
  /// 成功
  success,
  
  /// 失败
  failed,
  
  /// 错误
  error,
  
  /// 空数据
  empty,
  
  /// 无网络
  offline,
  
  /// 刷新中
  refreshing,
  
  /// 加载更多
  loadingMore,
  
  /// 正在处理
  processing,
  
  /// 已完成
  completed,
  
  /// 无权限
  unauthorized,
  
  /// 禁止访问
  forbidden,
  
  /// 待机状态
  idle,
}

/// 应用状态扩展方法
extension AppStatusExtension on AppStatus {
  /// 是否为加载状态
  bool get isLoading => 
    this == AppStatus.loading || 
    this == AppStatus.initializing || 
    this == AppStatus.refreshing || 
    this == AppStatus.loadingMore ||
    this == AppStatus.processing;
  
  /// 是否为错误状态
  bool get isError => 
    this == AppStatus.error || 
    this == AppStatus.failed || 
    this == AppStatus.offline || 
    this == AppStatus.unauthorized || 
    this == AppStatus.forbidden;
  
  /// 是否为成功状态
  bool get isSuccess => 
    this == AppStatus.success || 
    this == AppStatus.completed ||
    this == AppStatus.loaded;
  
  /// 是否处于完成状态
  bool get isCompleted => this == AppStatus.completed;
  
  /// 是否为空状态
  bool get isEmpty => this == AppStatus.empty;
  
  /// 是否为离线状态
  bool get isOffline => this == AppStatus.offline;
  
  /// 是否为未授权状态
  bool get isUnauthorized => this == AppStatus.unauthorized;
  
  /// 转换为可读的字符串
  String toReadableString() {
    switch (this) {
      case AppStatus.initial:
        return '初始状态';
      case AppStatus.initializing:
        return '初始化中';
      case AppStatus.loading:
        return '加载中';
      case AppStatus.loaded:
        return '已加载';
      case AppStatus.success:
        return '成功';
      case AppStatus.failed:
        return '失败';
      case AppStatus.empty:
        return '无数据';
      case AppStatus.error:
        return '错误';
      case AppStatus.offline:
        return '离线';
      case AppStatus.refreshing:
        return '刷新中';
      case AppStatus.loadingMore:
        return '加载更多';
      case AppStatus.processing:
        return '处理中';
      case AppStatus.completed:
        return '已完成';
      case AppStatus.unauthorized:
        return '未授权';
      case AppStatus.forbidden:
        return '禁止访问';
      case AppStatus.idle:
        return '待机';
    }
  }
} 